package com.zmc.third.infrastructure.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.zmc.third.infrastructure.dao.RefundInfoDao;
import com.zmc.third.infrastructure.entity.RefundInfoEntity;
import com.zmc.third.infrastructure.service.RefundInfoService;
import org.springframework.transaction.annotation.Transactional;


/**
 * @author zmc
 */
@Service("refundInfoService")
public class RefundInfoServiceImpl extends ServiceImpl<RefundInfoDao, RefundInfoEntity> implements RefundInfoService {


    @Override
    public RefundInfoEntity getByOrderSn(String orderSn) {
        LambdaQueryWrapper<RefundInfoEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(RefundInfoEntity::getOrderSn, orderSn).last(" limit 1");
        return getOne(wrapper);
    }

    @Override
    @Transactional
    public void updateStatusByOrderSnAndRefundSn(String orderSn,String status) {
        LambdaUpdateWrapper<RefundInfoEntity> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(RefundInfoEntity::getOrderSn, orderSn)
                .set(RefundInfoEntity::getRefundStatus, status);
        update(wrapper);
    }
}